#include "mesh.h"

void Transform(const std::string& attribute, Mesh* mesh, const Mat4x4n& T) {
	for(size_t i = 0; i < mesh->SizeNodes(); i++) {
		Node* n = mesh->GetNode(i);
		Vec3n& P = n->Get<Vec3n>(attribute);
		math::Vec4f x = T * math::V4n(P, 1.0);
		P = math::V3n(x[0], x[1], x[2]);
	}
}

void TransformConstrained(const std::string& attribute, Mesh* mesh, const Mat4x4n& T, const std::string& markAttribute, const size_t mark) {
	for(size_t i = 0; i < mesh->SizeNodes(); i++) {
		Node* n = mesh->GetNode(i);
		if(n->Get<size_t>(markAttribute) != mark) {
			Vec3n& P = n->Get<Vec3n>(attribute);
			math::Vec4f x = T * math::V4n(P, 1.0);
			P = math::V3n(x[0], x[1], x[2]);
		}
	}
}
